
<?php 
	include_once("web_header.php");
?>
<script type="text/javascript"  src="/include/ajaxfileupload.js"></script>

 
<div class="web_wrap">
    <div class="reg_content_wrap">
         <div  style="width:25%;float:left;">
        <?php 
          include_once("web_coach_dashmenu.php");
        ?>
         </div>
         <div class="dash_rightdiv">
         



<div id="regbox">

     <div id="regform" style="width:100%">
		       <!-- step 1 -->
           <div class="subhead"> 
               <span class="glyphicon glyphicon-star"></span>  编辑认证信息
           </div>

		       <div id="step1" style=" position:relative; ">


 				     <div class="formgroup" style="height:220px; padding:10px;">
					        <div>身份认证</div>
                  <div style="margin-top:5px; margin-bottom:5px;color:#999999">请上传本人身份证正面照,只用于核实身份真实性，其他人不可见。</div>
                   <div style="margin:10px;">
					              <img src="<?=$coach->idcard?>" id="idcard" style="width:200px; height:150px;"> 
 		                    <input id="userthumbfile" name="file" type="file" accept="image/*;capture=camera" onchange="upload('userthumbfile')" style="opacity:0; height:1px; width:1px; -webkit-appearance: none;  -moz-appearance: none; appearance: none; overflow: hidden;  " >
   					      </div>
					   </div>


             <div class="formgroup" style="height:200px; padding:10px">
                  <div>专业资质认证</div>
                  <div style="margin-top:5px; margin-bottom:5px;color:#999999">曾经获得过的专业教练资格认证证书</div>
                  <div style="margin:10px;">
                        <img src="<?=$coach->cert1?>" id="cert1" style="width:200px; height:150px;"> 
                   </div>
                   <div style="display:none">
                        <span certid="1" class="addcert">add</span>
                   </div>
             </div> 
             <div class="blankbox"></div>

		        </div>
 
	</div>		    

	      <div style="width:90%;  text-align:center; margin:auto; margin-top:20px;">
				  <button id="submitButton" type="" class="btn btn-primary">
				     <div id="submitButtonText">设置</div>
				  </button>
	      </div>

	 	  <div style="height:20px;">
	       </div>

</div>
	    
 


         </div>
                  <div style="clear:both"></div>

     </div>
</div>



 
 
<script type="text/javascript">

   var userid = '';
   var phonenumber = '';
   var wx_openid = '';

   var currentimg = null;
   $("#idcard").on('click',function(){
         $("#userthumbfile").click();
         currentimg = 'idcard';
   });
   $("#cert1").on('click',function(){
         $("#userthumbfile").click();
         currentimg = 'cert1';
   });


   $(".addcert").on('click',function(){
       var certid = $(this).attr("certid");
       if(certid='1'){
             $("#cert2div").show();
       }  
       if(certid='2'){
             $("#cert3div").show();
       }  
   });


  function upload (fileupload_id) {

	  	layer.open({
		    content: '正在上传',
		    className: 'bluelayer'
  		});

   
       //$("#uploadbg").attr("src","images/uploadbg2.png"); 
      
        $.ajaxFileUpload({
             url         :'/api_fileupload.php',
             secureuri   :false,
             fileElementId  : fileupload_id ,
             dataType    : 'json',
             success: function (data, status)            //相当于java中try语句块的用法
             {
                 //$("#idcard").attr("src",data.filepath);
                 $("#"+currentimg).attr("src",data.filepath);

                    layer.open({
            				    content: '上传成功',
            				    className: 'bluelayer',
            				    time: 1
            				});

             },
             error: function (data, status, e)            //相当于java中catch语句块的用法
             {
                layer.open({
				        content: '出错了!可能是网络有点慢,请尝试从手机相册中选择照片上传',
				        tbtn: ['OK']
				     });
                //$("#uploadbg").attr("src","images/uploadbg.png"); 
              }

         });
        return true;
   }

 
    var currentstep = 1;
    $("#submitButton").on('click',function(){
    	   sendInfo_1();
    });

    function showlayer(showword){
			layer.open({
			    content:showword,
			    style: 'background-color:#09C1FF; color:#fff; border:none;',
			    time: 2
			});
    }

    function sendInfo_1(){

   
 	    var idcard = $("#idcard").attr("src");
 	    var cert1 = $("#cert1").attr("src");
 
 	    layer.open({
  		    content: '正在提交',
  		    className: 'bluelayer'
  		});

        $.ajax({
            url: '/index.php/coach/web_dashboard_certinfo_handle',
            type: 'POST',
            data:{wx_openid:wx_openid, idcard:idcard, cert1:cert1},
            dataType: 'json',
            error: function(){
                  alert('Error loading PHP document'); 
                  posting = false;
             },
            success: function(result){
 
         				if(result.result==7){   
                      layer.open({
                						    content: '请重新登录',
                						    className: 'bluelayer',
                						    time: 233
                					  });
                      return;
                 }

                if(result.result==1){
                      layer.open({
            						    content: '修改完成',
            						    className: 'bluelayer',
            						    time: 2
            						});
                      return;
                }else{
                      layer.open({
          						    content: '请填写完整',
          						    className: 'bluelayer',
          						    time: 2
          						});
                      return;
                }
                posting = false;
            }
        });

    }

 
 
</script>




<?php 
	include_once("web_footer.php");
?>
